package com.lora.judge.type;

import com.lora.judge.CheckModel;

import java.math.BigDecimal;

/**
 * 等于比较
 * begin < target < end 返回 false 表示到达预警值，验证失败
 */
public class RangeCheck extends CheckModel {

    private static RangeCheck check;
    private RangeCheck() {}
    public static RangeCheck getInstance() {
        if(check == null) {
            check = new RangeCheck();
        }
        return check;
    }

    @Override
    public boolean checkDate() {
        return false;
    }

    @Override
    public boolean checkDateTime() {
        return false;
    }

    @Override
    public boolean checkInt() {
        return false;
    }

    @Override
    public boolean checkLong() {
        return false;
    }

    @Override
    public boolean checkBigDecimal() {
        BigDecimal target = (BigDecimal) this.target;
        BigDecimal begin = (BigDecimal) this.begin;
        BigDecimal end = (BigDecimal) this.end;
        return !(begin.doubleValue() < target.doubleValue() && target.doubleValue() < end.doubleValue());
    }

    @Override
    public boolean checkString() {
        return false;
    }
}
